home *** CD-ROM | disk | FTP | other *** search
- /****** axuucp/rn-addgroup ***************************************************
- *
- * NAME
- * rn-addgroup - Add a new group to the system
- *
- * SYNOPSIS
- * rx rn-addgroup.rexx [groupname]
- *
- * DESCRIPTION
- * This script adds a new group to the AXsh news system. The .lowest and
- * .next files will be initialized and it will be added to the AXsh
- * /usr/spool/news/NewsGroup file.
- *
- * AUTHOR
- * Tobias Ferber <tf@ganymed.hall.sub.org>
- *
- ******************************************************************************
- *
- */
-
- axnews = axconfig("news")
- newsgroups = axconfig("newsgroupfile")
-
- group_name = arg(1)
-
- if (words(group_name) < 1) then do
- say "usage: rx rn-addgroup.rexx [groupname]"
- exit
- end
-
- group_path = axnews || translate(group_name,'/','.')
-
- if exists(group_path) then do
- say "Newsgroup already exists:" group_name
- exit 5
- end
-
- say group_path
- call makepath(group_path)
- address command 'Echo "0" >' group_path || '/.lowest'
- address command 'Echo "0" >' group_path || '/.next'
- address command 'Echo "' || group_name || ' 60" >>' newsgroups
- exit 0
-
-
- /*@<pathonly><makepath><canexist><axconfig>*/
-
- /* return the non-file part of a pathname */
-
- pathonly: procedure
- parse arg path
- if (words(path) > 0) & (right(path,1) ~= ':') then do
- if right(path,1) = '/' then path= left(path,length(path)-1)
- if lastpos('/',path) > lastpos(':',path) then path= left(path,lastpos('/',path)-1)
- else path= left(path,lastpos(':',path))
- end
- return path
-
-
-
- /* create all non-existant directories in a path */
-
- makepath: procedure
- parse arg path
- if right(path,1) = '/' then path= left(path,length(path)-1)
- if ~exists(path) then do
- call makepath( pathonly(path) )
- address command 'MakeDir NAME "'path'"'
- end
- return 0
-
-
- /*
- * return 1 if the device or volume name in given pathname exists
- * or if no device or volume was present (current device)
- * 0 if the device or volume name does not exist
- */
-
- canexist: procedure
- parse upper arg path
- if pos(':',path) < 1 then return 1 /* current device */
- call pragma('W','N')
- return exists( left(path,lastpos(':',path)) )
-
-
-
- /* get an AXsh configuration value */
-
- axconfig: procedure
- tempfile = "T:axconfig." || pragma('Id')
- rc_index = "AXsh:rexx/rc.index"
- var_val=""; var_file=""; var_defval="";
-
- parse upper arg var_name
- if left(var_name,1) ~= '%' then var_name = '%'var_name
- if right(var_name,1) ~= ':' then var_name = var_name':'
-
- if open('idx',rc_index,'Read') then do
- do until (eof('idx') | (var_file~=''))
- str= translate(readln('idx'),' ',d2c(9))
- if words(str) > 0 then do
- parse var str vname ' ' fname '"' defval '"'
- if upper(vname) = var_name then do
- var_file= strip(fname,'B',' 'd2c(9))
- var_defval= defval
- end
- end
- end
- call close('idx')
- end
- else say 'Could not read "'rc_index'"'
-
- if words(var_file) > 0 then do
- if open('rc',var_file,'Read') then do
- do until (eof('rc') | (var_val~=''))
- str= translate(readln('rc'),' ',d2c(9))
- if upper(word(str,1)) = var_name then var_val = strip(readln('rc'),'B',' 'd2c(9))
- end
- call close('rc')
- end
- else say 'Could not examine "'var_file'" for' var_name
- end
- else do
- if words(var_defval) > 0 then var_val= var_defval
- else say 'No such config variable:' var_name
- end
-
- return var_val
-
-